<?php
/**
 * Project: zerg
 * User: yimudi
 * Date & Time: 2017/9/7 10:37
 */

namespace app\api\controller\v1;

use app\api\model\Banner as BannerModel;
use app\api\validate\IDMustBePositiveInt;
use app\lib\exception\BannerMissException;

class Banner
{
    /**
     * 获取指定id的banner信息
     * @url /banner/:id
     * @http GET
     * @param $id banner的ID号
     * @return mixed
     */
    public function getBanner($id)
    {
        (new IDMustBePositiveInt())->goCheck();

        $banner = BannerModel::getBannerByID($id);
        if ($banner->isEmpty()) {
            throw new BannerMissException();
        }

        return $banner;
    }
}